﻿using UnityEngine;
using System.Collections;

namespace Room
{
    public class RCAIChariotFactoryPrepareComplete : RCAIChariotFactoryBase
    {
        float makeTime;
        float timeline;
        protected override void OnEnter()
        {
            if (controller.objAni != null && controller.dictData.IsField==1)
            {
                var str = "";
                if (controller.Camp == 0)
                {
                    str = "make01";
                }
                else if (controller.Camp == 1)
                {
                    str = "make02";
                }

                var clip = controller.objAni.GetClip(str);
                if (clip != null)
                {
                    makeTime = clip.length;
                }

                controller.PlaySceneAni(str);
            }
            else
            {
                makeTime = 0f;
            }
            timeline = 0f;
        }

        protected override void OnTick()
        {
            timeline += Time.deltaTime;
            if(timeline > makeTime)
            {
                controller.SwitchState((int)UnionChariotFactoryState.Complete);
            }
        }

    }
}